﻿using System.Windows;
using LaserTag.Infrastructure.Events;
using Microsoft.Practices.Composite.Events;

namespace LaserTag.Shell
{
    public partial class ShellWindow : Window, IShellView
    {
        private IEventAggregator m_eventAggregator;

        public ShellWindow(IEventAggregator eventAggregator)
        {
            m_eventAggregator = eventAggregator;
            InitializeComponent();
            Unloaded += ShellWindow_Unloaded;
            MouseLeftButtonDown += ShellWindow_MouseLeftButtonDown;
        }

        public ShellWindow()
        {
            InitializeComponent();
            Unloaded += ShellWindow_Unloaded;
            MouseLeftButtonDown += ShellWindow_MouseLeftButtonDown;
        }

        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            m_eventAggregator.GetEvent<SystemShutdownEvent>().Publish(true);
            base.OnClosing(e);
        }

        void ShellWindow_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            DragMove();
        }

        private void ShellWindow_Unloaded(object sender, RoutedEventArgs e)
        {
           
        }

        #region IShellView Members

        void IShellView.Show()
        {
            Show();
        }

        #endregion
    }
}
